<%@ Page Language="C#" AutoEventWireup="true" Inherits="CRUD_View" Codebehind="View.aspx.cs" %>

<%@ Register Assembly="Pampa.CRUD" Namespace="Pampa.CRUD.UI.CustomControls" TagPrefix="cc1" %>

<%@ Register Assembly="Pampa.CRUD" Namespace="Pampa.WebControls" TagPrefix="cc2" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <link href="../../Css/Layout.css" rel="stylesheet" type="text/css"/>           
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <span class="title">Entity View</span>
        <br />
        <br />
        The main idea of this component is to manage the view of an entity and left to Pampa.Net the building of the page.
        We understand as an entity all classes of the Model which implement Pampa.CRUD.Core.IActiveRecord (see <a href="Entities.aspx">Entities</a>).
        You can control how the data of the entity is viewed through an XML configuration.
        <br />
        <br />
        <br />
        
        
        <span class="subtitle">XML Configuration</span>
        <br />
        <br />
        Firstly, we need to say Pampa.net were are the configuration files. 
		Then, this will be our configuration file to view a SimpleEntity 
		(see <a href="EntityEdit.aspx">EntityEdit</a> for more details about SimpleEntity and Framework configuration).<br/>
      
        
<pre class="codeBlock">
&lt;entity xmlns="urn:pampa-config"&gt;
  ...
  &lt;view&gt;
    &lt;HeaderGroup Id="MainData" Title="Main Data"&gt;
      &lt;Items&gt;
        &lt;ViewItem Id="Property1" Label="Property1" ValueWidth="200"/&gt;
        &lt;ViewItem Id="Property2" Label="Property2" ValueWidth="200"/&gt;
      &lt;/Items&gt;
    &lt;/HeaderGroup&gt;
  &lt;/view>
  ...  
&lt;/entity&gt;
</pre>

        <br />
        We can see above the definition of one group of data with two items (both of them ViewItems).
        Note: HeaderGroups and ViewItems are the only type of groups an items allowed.
        <br />
        <br />
        <br />


        <span class="subtitle">Code Behind</span>
        <br />
        <br />
        In order to view a new instance of our SimpleEntity class we create the instance, set some values for its attributes and then
        we pass the instance to the EntityView control. 
        <br />
        
<pre class="codeBlock">
<span class="keyword">protected void</span> Page_Load(<span class="keyword">object</span> sender, <span class="className">EventArgs</span> e)
{
   <span class="className">SimpleEntity</span> simpleEntity = <span class="keyword">new</span> <span class="className">SimpleEntity</span>();
   simpleEntity.Property1 = <span class="string">"Property 1"</span>;
   simpleEntity.Property2 = <span class="string">2</span>;
   <span class="keyword">this</span>.EntityView1.Entity = simpleEntity;
}
</pre>

        <br />
        

        <span class="subtitle">Entity View Working</span>       
        <br />         
        <br />
        Here we can see an EntityView control showing the instance of SimpleEntity class built above.
        <br />
        <br />
        <cc1:EntityView ID="EntityView1" runat="server" Width="200px"/>
        <br />         
        <br />



    </div>
    </form>
</body>
</html>
